﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SaladBar.Domain
{
    public class PagedQueryResult<T> : IEnumerable<T> where T : PersistentObject
    {
        private IEnumerable<T> _pagedResult;
        public int TotalCount { get; private set; }
        public int PageNumber { get; private set; }
        public int PageSize { get; private set; }
        public Func<IQueryable<T>, IQueryable<T>> Query { get; private set; }

        public PagedQueryResult(IEnumerable<T> pagedResult, int totalCount, int pageNumber, int pageSize, Func<IQueryable<T>, IQueryable<T>> query)
        {
            this._pagedResult = pagedResult;
            this.TotalCount = totalCount;
            this.PageNumber = pageNumber;
            this.PageSize = pageSize;
            this.Query = query;
        }

        public IEnumerator<T> GetEnumerator()
        {
            return this._pagedResult.GetEnumerator();
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return this._pagedResult.GetEnumerator();
        }
    }
}
